package org.lemon.transport.context.service.queue.discovery;

import lombok.Data;
import org.lemon.transport.context.data.tenant.TenantId;
import org.lemon.transport.context.service.queue.ServiceType;

@Data
public class QueueKey {

    private static final String MAIN = "Main";

    private final ServiceType type;
    private final String queueName;
    private final TenantId tenantId;

    public QueueKey(ServiceType type, String queueName, TenantId tenantId) {
        this.type = type;
        this.queueName = queueName;
        this.tenantId = tenantId;
    }

    public QueueKey(ServiceType type, TenantId tenantId) {
        this.type = type;
        this.queueName = MAIN;
        this.tenantId = tenantId != null ? tenantId : TenantId.SYS_TENANT_ID;
    }

    public QueueKey(ServiceType type) {
        this.type = type;
        this.queueName = MAIN;
        this.tenantId = TenantId.SYS_TENANT_ID;
    }

    @Override
    public String toString() {
        return "QK(" + queueName + "," + type + "," +
                (TenantId.SYS_TENANT_ID.equals(tenantId) ? "system" : tenantId) +
                ')';
    }
}
